package review;

//import javafx.scene.transform.Scale;

import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class Dinner {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int num = 20;
        String[] names = new String[num];   //保存订餐人姓名
        String[] dishMegs = new String[num];    //保存所选信息，包括菜名及份数
        int[] times = new int[num]; //保存送餐时间
        String[] addresses = new String[num];   //保存送餐地址
        int[] states = new int[num];    //保存订单状态，0表示已预订，1表示已完成
        double[] sumPrices = new double[num];   //保存订单的总金额

        String[] food = {"红烧鱼头", "猪肉炒白菜", "清蒸鲈鱼"};
        double[] price = {45, 16, 26.5};
        int praiseNums[]=new int[4];
        int select = 0;
        while (true) {
            //输出欢迎菜单
            System.out.println("欢迎使用吃货联盟订餐系统");
            System.out.println("---------------------------");
            System.out.println("1.我要订餐");
            System.out.println("2.查看餐袋");
            System.out.println("3.签收订单");
            System.out.println("4.删除订单");
            System.out.println("5.我要点赞");
            System.out.println("6.退出系统");
            System.out.println("---------------------------");
            select = in.nextInt();
            if (select == 1) {
                int numNull = 0;
                //先找到空位置
                for (; numNull < names.length; numNull++) {
                    if (names[numNull] == null)
                        break;//跳出for
                }
                //已满
                if (numNull == names.length) {
                    System.out.println("餐袋已满，请删除后再添加");
                    continue;
                }
                //显示菜品
                for (int i = 0; i < food.length; i++) {
                    System.out.println((i + 1) + " " + food[i] + " ￥" + price[i]);
                }
                //让用户选择
                int choice = 0;
                //赋值，比较，循环，一气呵成
                while ((choice = in.nextInt()) < 1 || choice > food.length) {
                    System.out.println("输入错误，重来");
                }
                System.out.println("你选择的是：" + food[choice - 1] + ",单价是" + price[choice - 1]);
                System.out.print("购买份数：");
                int fenshu=0;
                while ((fenshu=in.nextInt())<=0){
                    System.out.println("订餐份数必须大于0");
                }
                int time=0;
                while ((time=in.nextInt())<8||time>20){
                    System.out.println("送餐世界在8-20点之间");
                }
                System.out.println("地址：");
                String addr=in.next();
                dishMegs[numNull] = food[choice - 1] + " " + fenshu + "份";
                times[numNull]=time;

                addresses[numNull]=addr;
                sumPrices[numNull]=price[choice - 1]*fenshu;
                sumPrices[numNull]+=sumPrices[numNull]>=50?0:5;
                System.out.println("订餐成功");
            }else if(select==2){

            }else if(select==5){
                System.out.println("--我要点赞--");
                System.out.println("序号\t名称\t\t单价\t点赞数");
                for (int j = 0; j < food.length; j++) {
                    System.out.println((j + 1) + "\t" + food[j] + "\t\t" + price[j] + "\t" + praiseNums[j]);
                }
                System.out.println("请选择点赞的菜品序号:");
                int caiZanNum =0;
                //赋值，比较，循环，一气呵成
                while ((caiZanNum = in.nextInt()) < 1 || caiZanNum > food.length) {
                    System.out.println("输入错误，重来");
                }
                praiseNums[caiZanNum-1] ++;
//                for (int j = 0; j < food.length; j++) {
//                    if (caiZanNum == j + 1) {
//                        praiseNums[j] += 1;
//                    }
//                }
                System.out.println("点赞后的菜品展示:");
                System.out.println("序号\t名称\t\t单价\t点赞数");
                for (int j = 0; j < food.length; j++) {
                    System.out.println((j + 1) + "\t" + food[j] + "\t\t" + price[j] + "\t" + praiseNums[j]);
                }

            }
            System.out.println("输入任何值返回");
            String r=in.next();
        }

    }
}

